import { request } from "@/api/service";
import { BUTTON_STATUS_NUMBER } from "@/config/button";
import { urlPrefix as complaintsPrefix } from "./api";


export const crudOptions = vm => {
  return {
    pageOptions: {
      compact: true,
      export: {
        local: true,//本地导出，false为服务端导出
      },
    },
    options: {
      tableType: "vxe-table",
      rowKey: true, // 必须设置，true or false
      rowId: "id",
      height: "100%", // 表格高度100%, 使用toolbar必须设置
      highlightCurrentRow: false
    },
    rowHandle: {
      width: 140,
      view: {
        thin: true,
        text: "",
        disabled() {
          return !vm.hasPermissions("Retrieve");
        }
      },
      edit: {
        thin: true,
        text: "",
        disabled() {
          return !vm.hasPermissions("Update");
        }
      },
      remove: {
        thin: true,
        text: "",
        disabled() {
          return !vm.hasPermissions("Delete");
        }
      }
    },
    indexRow: {
      // 或者直接传true,不显示title，不居中
      title: "序号",
      align: "center",
      width: 70
    },
    viewOptions: {
      componentType: "form"
    },
    formOptions: {
      defaultSpan: 24, // 默认的表单 span
      width: "35%"
    },
    columns: [{
      title: "ID",
      key: "id",
      show: false,
      disabled: true,
      width: 90,
      form: {
        disabled: true
      }
    },
    {
      title: "企业名称",
      key: "企业名称",
      width: 200,
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "企业名称必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入企业名称"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "统一社会信用代码",
      key: "统一社会信用代码",
      width: 200,
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "统一社会信用代码必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入统一社会信用代码"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "辖区",
      key: "辖区",
      width: 100,
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "辖区必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入辖区"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "抽检年度",
      key: "抽检年度",
      width: 100,
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true,
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "抽检年度必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入抽检年度"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "行业",
      key: "行业",
      width: 100,
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "行业必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入行业"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "评分等级",
      key: "评分等级",
      width: 100,
      sortable: true,
      treeNode: true,

      type: "select",
      search: {
        disabled: false,
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "评分等级必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入评分等级"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      },

      dict: {  //本地数据字典
        data: [
          { value: 'A', label: 'A' },
          { value: 'B', label: 'B' },
          { value: 'C', label: 'C' },
          { value: 'D', label: 'D' },
        ]
      }
    },
    {
      title: "产品风险因素",
      key: "产品风险因素",
      sortable: true,
      treeNode: true,

      type: "number",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "产品风险因素必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入产品风险因素"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "监督抽查",
      key: "监督抽查",
      sortable: true,
      treeNode: true,

      type: "number",

      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "监督抽查必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入监督抽查"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "现场检查",
      key: "现场检查",
      sortable: true,
      treeNode: true,

      type: "number",

      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "现场检查必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入现场检查"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "行政处罚",
      key: "行政处罚",
      sortable: true,
      treeNode: true,

      type: "number",

      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "行政处罚必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入行政处罚"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "举报查实情况",
      key: "举报查实情况",
      sortable: true,
      treeNode: true,

      type: "number",

      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "举报查实情况必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入举报查实情况"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "企业质量信用风险因素",
      key: "企业质量信用风险因素",
      sortable: true,
      treeNode: true,

      type: "number",

      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "企业质量信用风险因素必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入企业质量信用风险因素"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "通报召回",
      key: "通报召回",
      sortable: true,
      treeNode: true,

      type: "number",

      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "通报召回必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入通报召回"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "网络舆情",
      key: "网络舆情",
      sortable: true,
      treeNode: true,

      type: "number",

      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "网络舆情必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入网络舆情"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "风险监测",
      key: "风险监测",
      sortable: true,
      treeNode: true,

      type: "number",

      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "风险监测必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入风险监测"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "企业通用信用风险因素",
      key: "企业通用信用风险因素",
      sortable: true,
      treeNode: true,

      type: "number",

      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "企业通用信用风险因素必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入企业通用信用风险因素"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    ].concat(vm.commonEndColumns())
  };
};
